Function.prototype.myCall = function(obj = window, ...args) {
    const fn = Symbol('fn')
    obj[fn] = this
    obj[fn](...args)
    delete obj[fn]
}

Function.prototype.myApply = function(obj = window, args) {
    const fn = Symbol('fn')
    obj[fn] = this
    obj[fn](...args)
    delete obj[fn]
}

Function.prototype.myBind = function(thisArg, args) {
    console.log(args)
    let self = this
    let fbound = function() {
        self.apply(this instanceof self ? this : thisArg, [args, ...arguments])
    }
    fbound.prototype = Object.create(self.prototype) 
    return fbound
}

const obj = {
    name: 'kaho',
    age: 28
}

const foo = function(...args) {
    console.log(args)
    return this.name + args[0]
}

// let res = foo.myApply(obj, [1,2])

// console.log(res)

foo.myBind(obj, [1,2,3])()